package homework.api06_2;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class BwDemo {
    public static void main(String[] args) {
        try(
                FileOutputStream fos = new FileOutputStream("myNote_2.txt",true);
                OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
                BufferedWriter bw = new BufferedWriter(osw);
                PrintWriter pw = new PrintWriter(bw,true);
        ){
            Scanner scanner = new Scanner(System.in);
            while (true) {
                System.out.println("输入内容，单独输入exist退出：");
                String str = scanner.nextLine();
                if (str.equals("exist")){
                    break;
                }
                pw.println(str);
            }
        }catch (IOException e){
            System.out.println("出错。");
        }
    }
}
